package com.cdm.beans.cdm;

import net.sf.frails.JSFHelper;
import net.sf.frails.actions.BaseAction;
import net.sf.frails.bean.annotations.DefMbean;
import net.sf.frails.bean.annotations.PreRestoreView;
import net.sf.frails.bean.annotations.Prop;
import net.sf.frails.utils.WebResourceUtils;

import org.apache.myfaces.custom.fileupload.UploadedFile;

@DefMbean
public class ContentTranscodeBean extends BaseAction {
	@Prop
	UploadedFile uploadedFile;

	@Prop
	String name;

	@Prop
	String id = "Cain";

	@PreRestoreView
	public void listen() {
		System.out.println("\nlistening restore view " + getClass() + "\n");
	}

	public String upload() {
		name = WebResourceUtils.parseUploadedFilename(uploadedFile.getName());
		WebResourceUtils.upload(uploadedFile, name);
		JSFHelper.addMessage("上传成功");
		return "";
	}
}
